package pentago.engine;

public class Watchman extends Thread {

    private long sleepTime;
    private IPentagoAlgorithm algorithm;

    Watchman(long sleepTime, IPentagoAlgorithm algorithm) {
	this.sleepTime = sleepTime;
	this.algorithm = algorithm;
    }

    public void run() {
	try {
	    Watchman.sleep(sleepTime);
	} catch (InterruptedException e) {
	}
	algorithm.executeTimeout();
    }

    public void shutdown() {
	if (this.isAlive())
	    this.interrupt();
    }
}